package com.py.chat.client.businese;

import com.py.chat.UI.UI;
import com.py.chat.proto.IBusineseHandle;

import java.text.SimpleDateFormat;
import java.util.List;

import com.google.protobuf.MessageLite;
import com.py.chat.proto.ChatProbuf.ChatLog;
import com.py.chat.proto.ChatProbuf.STCChatLogsRet;
import com.py.chat.proto.ChatProbuf.STCChatRet;

public class ClientChatLogsRetHandle extends IBusineseHandle<STCChatLogsRet>{

	@Override
	public MessageLite handle(STCChatLogsRet msg) {
		
		int status = msg.getStatus();
		String message = msg.getMsg();
		UI.msgUI(message);
		//失败
		if(status == 0){
			// do nothing
		}else{
			List<ChatLog> chatLogs= msg.getChatLogsList();
			UI.msgUI("一共有"+chatLogs.size()+"条记录");
			for(ChatLog chatLog:chatLogs){
				SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/ss HH:mm:ss  ");
				String dateStr = df.format(chatLog.getCreateDate());
				UI.reMsgUI(dateStr, chatLog.getSendUserName(), String.valueOf(chatLog.getSendUserLevel()), chatLog.getMsg());
			}
		}
		
		
		return null;
	}

}
